package edu.washington.cs.workflow.analysis.guistructure;

import edu.washington.cs.workflow.util.Utils;

public class UIMethodEntity extends UIAbstractEntity {
	
	public static String TYPE = EventEntity.TYPE.UIMethodEntity.toString() + ": ";

	public UIMethodEntity(String methodDesc, Object obj, boolean entryOrExit) {
		super(methodDesc, obj, entryOrExit);
	}
	
	public UIMethodEntity(String methodDesc, int hashCode, boolean entryOrExit, long timestamp) {
		super(methodDesc, hashCode, entryOrExit, timestamp);
	}
	
	@Override
	public String toString() {
		return TYPE + EventEntity.SEP + super.strContent();
	}
	
	public static UIMethodEntity recover(String line) {
		String[] items = line.split(EventEntity.SEP);
		Utils.checkTrue(items.length == 5);
		Utils.checkTrue(items[0].equals(TYPE));
		String methodDesc = items[1];
		boolean isEntry = Boolean.parseBoolean(items[2]);
		int thizObj = Integer.parseInt(items[3]);
		long timestamp = Long.parseLong(items[4]);
		return new UIMethodEntity(methodDesc, thizObj, isEntry, timestamp);
	}
}
